import store from '@/store/index.js'
let list = ["navigateTo", "redirectTo", "reLaunch", "switchTab"]
let routesWhitelist = ['/pages/tabs/classify','/pages/tabs/study','/pages/tabs/mine'] // 可以直接跳转的路由
let routesMap = ['/pages/shopping/index'] // 必须登录之后才能跳转的路由
// 路由拦截
list.forEach((item)=> {
	uni.addInterceptor(item,{
		invoke(args) {
			let userToken = store.state.user.token
			console.log('跳转的参数', args)
			if (routesWhitelist.includes(args.url) || !userToken && args.url === '/pages/login/index') {
				return true
			}
			if (!userToken && routesMap.includes(args.url)) {
					// uni.showToast({
					// 	title: '您还未登录哦',
					// 	icon: 'error'
					// })
					uni.navigateTo({
						url: '/pages/login/index',
						
					})
					return false
			}
			return true
		}
	})
})